<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Java Service Wrapper - Starting at Reboot (Debian Linux)</title>
<style media="all" type="text/css">
            @import url("./style/wrapper.css");
        </style>
</head>
<body bgcolor="#eeeeff" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" alink="#023264" vlink="#023264" link="#525D76" text="#000000">
<map name="wrapperLogo">
<area href="http://wrapper.tanukisoftware.org" coords="90,90,88" shape="circle">
</map>
<map name="wrapperTitle">
<area href="http://www.tanukisoftware.com" coords="28,32,176,48" shape="rect">
</map>
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td valign="top" width="180">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td width="180"><img usemap="#wrapperLogo" border="0" height="180" width="180" src="images/WrapperLogo.png"></td>
</tr>
<tr>
<td>
<table cellpadding="4" cellspacing="0" width="100%" border="0">
<tr>
<td nowrap="true">
<div id="menu">
<script language="JavaScript">//@@MENU_TOP@@</script>
<div>
<b>Essentials</b>
<div>
<a href="introduction.html">Introduction</a>
</div>
<div>
<a href="integrate.html">Integration Methods</a>
</div>
<div>
<a href="properties.html">Configuration Properties</a>
</div>
<div>
<a href="launch.html">Launching Your Application</a>
</div>
<div>
<b>
                        &gt;&gt;
                        <a href="donate.html">Show Your Support</a>
                        &lt;&lt;
                    </b>
</div>
<div>
<a href="sponsors.html">Sponsors</a>
</div>
</div>
<div>
<b>Documentation</b>
<div>
<a href="jmx.html">JMX Control</a>
</div>
<div>
<a href="security-model.html">Security Model</a>
</div>
<div>
<a href="example.html">Feature Examples</a>
</div>
<div>
<a href="debugging.html">Debugging Your Application</a>
</div>
<div>
<a href="troubleshooting.html">Troubleshooting</a>
</div>
<div>
<a href="faq.html">FAQ</a>
</div>
<div>
<a href="release-notes.html">Release Notes</a>
</div>
<div>
<a href="history.html">Project History</a>
</div>
<div>
<a href="javadocs.html">Javadocs API</a>
</div>
<div>
<a href="buttons.html">Buttons</a>
</div>
<div>
<a href="authors.html">Authors</a>
</div>
<div>
<a href="license.html">License</a>
</div>
</div>
<div>
<b>Download</b>
<div>
<a href="http://sourceforge.net/project/showfiles.php?group_id=39428&package_id=31591">Binaries</a>
</div>
<div>
<a href="http://sourceforge.net/project/showfiles.php?group_id=39428&package_id=33658">Source Code</a>
</div>
</div>
<div>
<b>Get Involved</b>
<div>
<a href="http://sourceforge.net/projects/wrapper/">Source Forge</a>
</div>
<div>
<a href="http://svn.sourceforge.net/viewvc/wrapper/">Subversion Repository</a>
</div>
<div>
<a href="http://sourceforge.net/tracker/?group_id=39428">Issue Tracking</a>
</div>
<div>
<a href="http://sourceforge.net/mail/?group_id=39428">Mailing Lists and Archives</a>
</div>
<div>
<a href="http://sourceforge.net/forum/?group_id=39428">Forums (Old)</a>
</div>
</div>
</div>
<script language="JavaScript">//@@MENU_BOTTOM@@</script>
<p>
<b>Hosted by:</b>
<br>
<a href="http://sourceforge.net/projects/wrapper/"><img alt="SourceForge" border="0" height="31" width="88" src="http://sourceforge.net/sflogo.php?group_id=39428"></a>
<br>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td><td valign="top" width="*">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td colspan="3"><img height="4" src="images/spacer.gif"></td>
</tr>
<tr>
<td align="center" height="90" colspan="2"><a href="http://wrapper.tanukisoftware.org"><img border="0" height="90" width="728" src="images/OfflineAd728x90.png"></a></td><td rowspan="5"><img width="4" src="images/spacer.gif"></td>
</tr>
<tr>
<td height="49" width="435"><img usemap="#wrapperTitle" border="0" height="49" width="435" src="images/WrapperTitle.png"></td><td valign="bottom" align="right" width="*"><a href="donate.html"><img border="0" height="16" width="300" src="images/DonationRequest.png"></a></td>
</tr>
<tr>
<td height="4" colspan="2"><img height="4" width="500" src="images/BorderTop.png"></td>
</tr>
<tr>
<td colspan="2">
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td valign="top" width="4"><img height="496" width="4" src="images/BorderLeft.png"></td><td bgcolor="#ffffff" valign="top" width="*" colspan="2">
<table cellpadding="4" cellspacing="0" width="100%" border="0">
<tr>
<td nowrap="true" align="center"><font zcolor="#115b77" color="#8888aa" size="5"><b>Starting at Reboot (Debian Linux)</b></font></td>
</tr>
<tr>
<td>
<title>Starting at Reboot (Debian Linux)</title>
    
    
<a name="N10009"></a>
<table cellpadding="2" cellspacing="0" width="100%" border="0">
<tr>
<td bgcolor="#8888aa" class="sectionheader1" width="*"><font color="#eeeeee" size="4"><b>Launching Your Application</b></font></td>
</tr>
<tr>
<td><img height="4" width="1" src="./images/spacer.gif"></td>
</tr>
<tr>
<td>
        
        
<ul>
            
<li>
                
<a href="launch.html">All Platforms</a>
            
</li>
            
<li>
                
<a href="launch-nix.html">Linux / UNIX</a>
            
</li>
        
</ul>
    
</td>
</tr>
</table>
    
<a name="N10020"></a>
<table cellpadding="2" cellspacing="0" width="100%" border="0">
<tr>
<td bgcolor="#8888aa" class="sectionheader1" width="*"><font color="#eeeeee" size="4"><b>Installing The Application To Start on Reboot (Debian Linux)</b></font></td>
</tr>
<tr>
<td><img height="4" width="1" src="./images/spacer.gif"></td>
</tr>
<tr>
<td>
        
        
<ul>
            
<li>
                
<a href="#slink">Create Symbolic Link in <tt>/etc/init.d</tt></a>
            
</li>
            
<li>
                
<a href="#rc">Registering the Run Levels</a>
            
</li>
            
<li>
                
<a href="#urc">Unregistering the Run Levels</a>
            
</li>
        
</ul>
        
<a name="slink"></a>
<table cellpadding="2" cellspacing="0" width="100%" border="0">
<tr>
<td rowspan="3" width="10"><img height="1" width="10" src="./images/spacer.gif"></td><td bgcolor="#9999bb" class="sectionheader2" width="*"><font color="#eeeeee" size="3"><b>Create Symbolic Link in /etc/init.d</b></font></td>
</tr>
<tr>
<td><img height="4" width="1" src="./images/spacer.gif"></td>
</tr>
<tr>
<td>
            
            
<p>
                The first step in setting up the application so that it will
                shutdown cleanly when the system shutsdown and then starts up
                in the correct order when the system boots is to create a
                symbolic link to the applications script within the 
                <tt>/etc/init.d</tt> directory.
                Many applications simply copy their daemon script to this
                directory but the Wrapper's scripts require that a symolic
                link is used so that the location of the rest of the
                application's files can be located without modification to the
                script.
            </p>
            
<p>
                To create a symbol link in the <tt>/etc/init.d</tt>,
                you must be root. Simply enter the following sequence of commands:
            </p>
            
<table cellspacing="0" cellpadding="0" width="100%" border="0" class="listing">
<tr>
<td bgcolor="#eeeeee" class="listingcell"><font color="#444444">
<pre class="listingpre">ln -s /usr/lib/myapp/bin/myapp /etc/init.d/myapp</pre>
</font></td>
</tr>
</table>
            
<p>
                Now verify that the symbolic link is working correctly by changing
                the current directory to <tt>/etc/init.d</tt>
                and executing the following command.
            </p>
            
<table cellspacing="0" cellpadding="0" width="100%" border="0" class="listing">
<tr>
<td bgcolor="#eeeeee" class="listingcell"><font color="#444444">
<pre class="listingpre">./myapp console</pre>
</font></td>
</tr>
</table>
            
<p>
                Make sure to run as root as this will be the case when the
                application is started on system startup.  It is fairly common
                for their to be differences in the environment between the
                root user and the user you are normally logged in as.  These
                differences can cause problems like not being able to locate
                the JVM for example.
            </p>
            
<p>
                The application should start normally.  Press CTRL-C to stop the
                application.
            </p>
        
</td>
</tr>
</table>
        
<a name="rc"></a>
<table cellpadding="2" cellspacing="0" width="100%" border="0">
<tr>
<td rowspan="3" width="10"><img height="1" width="10" src="./images/spacer.gif"></td><td bgcolor="#9999bb" class="sectionheader2" width="*"><font color="#eeeeee" size="3"><b>Registering the Run Levels</b></font></td>
</tr>
<tr>
<td><img height="4" width="1" src="./images/spacer.gif"></td>
</tr>
<tr>
<td>
            
            
<p>
                We will want our application to be started for all multi-user
                run levels and stopped for the halt, single-user and reboot
                runlevels.  This can be accomplished by changing the current
                directory to <tt>/etc/init.d</tt>
                and then, as root, using the <tt>update-rc.d</tt>
                command:
            </p>
            
<table cellspacing="0" cellpadding="0" width="100%" border="0" class="listing">
<tr>
<td bgcolor="#eeeeee" class="listingcell"><font color="#444444">
<pre class="listingpre">update-rc.d myapp start 20 2 3 4 5 . stop 20 0 1 6 .</pre>
</font></td>
</tr>
</table>
            
<p>
                You should see the following output:
            </p>
            
<table cellspacing="0" cellpadding="0" width="100%" border="0" class="listing">
<tr>
<td bgcolor="#eeeeee" class="listingcell"><font color="#444444">
<pre class="listingpre"> Adding system startup for /etc/init.d/myapp ...
   /etc/rc0.d/K20myapp -&gt; ../init.d/myapp
   /etc/rc1.d/K20myapp -&gt; ../init.d/myapp
   /etc/rc6.d/K20myapp -&gt; ../init.d/myapp
   /etc/rc2.d/S20myapp -&gt; ../init.d/myapp
   /etc/rc3.d/S20myapp -&gt; ../init.d/myapp
   /etc/rc4.d/S20myapp -&gt; ../init.d/myapp
   /etc/rc5.d/S20myapp -&gt; ../init.d/myapp</pre>
</font></td>
</tr>
</table>
            
<p>
                The environment while booting is pretty sparse, so any references
                which make use of the path or environment variables may fail.  To
                save yourself some extra reboots to test your install, I would
                suggest setting the
                <tt>wrapper.logfile.loglevel</tt>
                property to <tt>DEBUG</tt> now.
            </p>
            
<p>
                You can now reboot your system to test the installation:
            </p>
            
<table cellspacing="0" cellpadding="0" width="100%" border="0" class="listing">
<tr>
<td bgcolor="#eeeeee" class="listingcell"><font color="#444444">
<pre class="listingpre">shutdown -r now</pre>
</font></td>
</tr>
</table>
            
<p>
                When the system comes back up it will hopefully be running.  If
                there were any problems, then the log file should contain some
                clues as to the problem.   If the test in the previous section
                worked but this failed, then the problem is most likely a
                problem with missing enviroment variables.
            </p>
            
<p>
                If your application makes use of other services, MySQL for example,
                then you will need to make sure that your application is started
                after MySQL, and then shutdown before MySQL.  This is done by
                controlling the startup/shutdown order. By default, MySQL starts
                and stops with an order of 20, so we can get the desired behavior by
                using a startup order of 21 and a shutdown order of 19.
            </p>
            
<table cellspacing="0" cellpadding="0" width="100%" border="0" class="listing">
<tr>
<td bgcolor="#eeeeee" class="listingcell"><font color="#444444">
<pre class="listingpre">update-rc.d myapp start 21 2 3 4 5 . stop 19 0 1 6 .</pre>
</font></td>
</tr>
</table>
        
</td>
</tr>
</table>
        
<a name="urc"></a>
<table cellpadding="2" cellspacing="0" width="100%" border="0">
<tr>
<td rowspan="3" width="10"><img height="1" width="10" src="./images/spacer.gif"></td><td bgcolor="#9999bb" class="sectionheader2" width="*"><font color="#eeeeee" size="3"><b>Unregistering the Run Levels</b></font></td>
</tr>
<tr>
<td><img height="4" width="1" src="./images/spacer.gif"></td>
</tr>
<tr>
<td>
            
            
<p>
                To unregister the run levels registered in the previous section,
                execute the following command.
            </p>
            
<table cellspacing="0" cellpadding="0" width="100%" border="0" class="listing">
<tr>
<td bgcolor="#eeeeee" class="listingcell"><font color="#444444">
<pre class="listingpre">update-rc.d -f myapp remove</pre>
</font></td>
</tr>
</table>
        
</td>
</tr>
</table>
    
</td>
</tr>
</table>

</td>
</tr>
<tr>
<td align="right" id="author">
<p>
<i>by Leif Mortenson</i>
</p>
</td>
</tr>
</table>
<script language="JavaScript">//@@BODY_SECTION@@</script></td><td valign="bottom" width="4"><img height="496" width="4" src="images/BorderRight.png"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" height="4" colspan="2"><img height="4" width="500" src="images/BorderBottom.png"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellpadding="2" cellspacing="0" border="0" width="100%">
<tr>
<td id="copyright" align="left"><font color="#525D76" size="-1" face="arial,helvetica,sanserif"><i>
                            Copyright &copy;1999-2004 by <a href="http://www.tanukisoftware.com">Tanuki Software</a>.
                            All Rights Reserved.
                        </i></font></td><td align="right"><font color="#525D76" size="-1" face="arial,helvetica,sanserif"><i>
                            last modified:
                            <script language="JavaScript"> document.write(document.lastModified); </script></i></font></td>
</tr>
</table>
</body>
</html>
